package com.dhcc.core.modules.system.warpper;

import java.util.Map;

import com.dhcc.core.framework.base.warpper.BaseControllerWarpper;
import com.dhcc.core.framework.util.CommonUtil;

/**
 * 日志列表的包装类
 * 
 * @ClassName: LogWarpper
 * @Description: TODO
 * @author: cyf
 * @date: 2018年1月2日 上午10:43:28
 */
public class LogWarpper extends BaseControllerWarpper {

    public LogWarpper(Object list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
        String message = (String) map.get("message");

        // 如果信息过长,则只截取前100位字符串
        if (CommonUtil.isNotEmpty(message) && message.length() >= 100) {
            String subMessage = message.substring(0, 100) + "...";
            subMessage = subMessage.replaceAll("<br/>","");
            subMessage = subMessage.replaceAll("<br>","");
            subMessage = subMessage.replaceAll(System.getProperty("line.separator"),"");
            map.put("message", subMessage);
        }

        map.put("regularMessage", message);
    }

}
